Repository navigation
fix(conversions): clean []map[any]any slices before JSON encoding - #193
Conversation
hanzei
left a comment
There was a problem hiding this comment.
Thanks!
Can you please explain why URLValuesSliceKeySuffix needs to be exported? What value does it add for callers?
|
Hi @hanzei, thanks for the review! The motivation for adding the
That being said, if you prefer keeping the public API surface minimal and not exposing the getter, I am more than happy to remove Let me know what you prefer and I can update the branch accordingly. |
hanzei
left a comment
There was a problem hiding this comment.
Thanks for the context. you're right that it was exported briefly in 2018 another PR made it private, so the comment has just been stale since then. That said, I'd prefer to keep the API surface as is: callers that change the suffix already know what they set it to, and save/restore is mostly a test concern. Please drop the URLValuesSliceKeySuffix() getter and the test changes, but keep the doc comment rename. The []map[any]any fix looks good and we can merge once that's done.
|
Thanks @hanzei! I've dropped the Branch is updated and ready for merge! |
Summary
Clean
[]map[any]anyslices before JSON encoding:cleanUp(v any)previously supported[]any,[]map[string]any,[]Map, andmap[any]any, but omitted[]map[any]any(slices of interface maps, e.g. from typed fields filled by YAML decoders or from dynamically built data).[]anyin Go type switches,[]map[any]anyfell through todefault: return v, resulting injson: unsupported type: map[interface {}]interface {}when callingJSON()orBase64().cleanUpInterfaceMapArray(in []map[any]any) []Mapand registeredcase []map[any]any:incleanUp.Fix stale doc comment:
urlValuesSliceKeySuffixvariable still used its old exported name,URLValuesSliceKeySuffix, from before it was made private in URLQuery with index slice keys #74.Tests:
[]map[any]anyinconversions_nil_test.go, and a nested case inTestConversionJSONinconversions_test.go.go test -v ./...).